import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Vant from "vant";
import { Lazyload } from "vant";
import "vant/lib/index.css";
import { getToken } from "./util/auth";
import { setCookie } from "./Hook/cookie";
const app = createApp(App);
app.use(router);
app.use(store);
app.use(Vant);
app.use(Lazyload, {
  lazyComponent: true,
});
app.mount("#app");

// router.beforeEach((to, from, next) => {
//   let token = getToken("token");
//   let uid = setCookie("uid");
//   console.log(uid);
//   const pagePath =
//     to.path == "/login" ||
//     to.path == "/verification" ||
//     to.path == "/loginpass";
//   if (!token) {
//     //判断有没有token，当前用户没有登录要到登录页
//     if (pagePath) {
//       next();
//     } else {
//       next(pagePath);
//     }
//   } else {
//     //用户已经登陆
//     if (pagePath) {
//       //用户已经登录了，正在登录页，打回首页
//       next("/");
//     } else {
//       next();
//     }
//   }
// });
